package com.xxx.datalake.config;

import org.apache.hadoop.fs.FileSystem;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;
import java.net.URI;

/**
 * @ Project: datalake-unstructured
 * @ Since: 2022/9/13 16:51
 * @ Description:
 */
@Configuration
public class HdfsClientConfig {

    @Value("${hdfs.URI}")
    private URI uri;

    @Value("${hdfs.user}")
    private String user;

    @Bean
    public FileSystem fileSystem() throws IOException, InterruptedException {
        org.apache.hadoop.conf.Configuration configuration = new org.apache.hadoop.conf.Configuration();
        return FileSystem.get(uri, configuration, user);
    }
}
